<?php
namespace Admin\Controller;
use \Think\Controller;
class LoginController extends Controller {
   
        public function log(){
        $user=M('admin');
        // var_dump($_POST);die;
        $arr['account'] = $_POST['name'];
        $arr['password'] = $_POST['password'];
        $data=$user->where($arr)->find();
        // var_dump($data);
        if($data>0){
                $_SESSION['account'] = $_POST['name'];
                $aid = M('admin')->field('id')->where('account="'.$_POST['name'].'"')->find()['id'];
                $_SESSION['aid'] = $aid;

                $this-> success('登录成功',U('Admin/Index/index'));
                // $_SESSION['pwd'] = $_POST['pwd'];
                var_dump($_SESSION);
            }else{
            $this->error('用户名或密码错误',U('Admin/Login/index'));
        }
    }

        public function logout(){
            session('aid',null);
            session('account',null);
            $this->success('注销成功',U('Login/index'));
        }

}